<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
var charu = function (nums){
    let temp
    for(var i = 1; i<nums.length ; i++){
        var j = i
        temp = nums[i]
        while( j>0 && (nums[j-1]>temp)){
            nums[j] = nums[j-1]
            j--
        }//  temp = 1  ( 举例 , [3,5,1] )
        //  循环开始
        //  [3,5,1] -> [3,5,5]
        //  [3,5,5] -> [3,3,5]
        //  循环结束 
        //  nums[j] = temp = 1
        //  [3,5,5] -> [1,3,5]
        nums[j] = temp
    }
    console.log(nums)
}
nums=[5,4,3,2,1,4,11,223,455,44,2211,99]
charu(nums)
    </script>
</body>
</html>